<div class="sectionY">
    <a href="javascript:history.back()">
        <img src="__PUBLIC__/home/images/a4.png" class="a1" alt="">
    </a>
    <p class="p1">累计收益</p>
<!--    <a href="" class="a3">兑换</a>-->
</div>
<div class="kong1"></div>
<div class="com_section1">
    <div class="com_section1_1">
        <p class="p1">累计收益</p>
        <p class="p2">{$userinfo.pushs}</p>
    </div>
</div>
<div class="com_section2">
    <div class="title">
        <p class="p1">累计收益明细</p>
    </div>
    <div class="center content">
        <div class="content1"></div>
    </div>
</div>

<script>
    var params = {
        page: 0,
        page_size: 10,
    };
    var mm;
    $(function () {

        var dh = $(window).height();
        $('body').height(dh)
        // dropload
        mm = $('.content').dropload({
            scrollArea: window,
            domUp: {
                domClass: 'dropload-up',
                domRefresh: '<div class="dropload-refresh" style="color: #ccc">↓下拉刷新</div>',
                domUpdate: '<div class="dropload-update" style="color: #ccc">↑释放更新</div>',
                domLoad: '<div class="dropload-load" style="color: #ccc"><span class="loading"></span>加载中</div>'
            },
            domDown: {
                domClass: 'dropload-down',
                domRefresh: '<div class="dropload-refresh" style="color: #ccc">↑上拉加载更多</div>',
                domLoad: '<div class="dropload-load" style="color: #ccc"><span class="loading"></span>加载中</div>',
                domNoData: '<div class="dropload-noData" style="color: #ccc">暂无更多数据</div>'
            },
            loadUpFn: function (me) {
                params.page = 1;
                var _html = '';
                $.ajax({
                    url: '{:url(\'Set/ajaxpopularize\')}',
                    data: params,
                    dataType: "JSON",
                    type: "POST",
                    success: function (res) {
                        var data = res;
                        if (data.length > 0) {
                            _html = formatList(data);
                        }
                        $('.content1').html(_html);
                        // 每次数据加载完，必须重置
                        me.resetload();
                        // 重置页数，重新获取loadDownFn的数据
                        page = 1;
                        // 解锁loadDownFn里锁定的情况
                        me.unlock();
                        me.noData(false);
                    },
                    error: function (res) {
                        alert(res);
                    }
                })
            },
            loadDownFn: function (me) {
                params.page++;
                var _html = '';
                $.ajax({
                    url: '{:url(\'Set/ajaxpopularize\')}',
                    data: params,
                    dataType: "JSON",
                    type: "POST",
                    success: function (res) {
                        var data = res;
                        if (data.length > 0) {
                            _html = formatList(data);
                        } else {
                            // 锁定
                            me.lock();
                            // 无数据
                            me.noData();
                        }
                        // 插入数据到页面，放到最后面
                        $('.content1').append(_html);
                        // 每次数据插入，必须重置
                        me.resetload();
                    },
                    error: function (res) {
                        alert(res);
                    }
                })
            },
            threshold: 50
        });
    });

    function formatList(data) {
        var _html = '';
        $.each(data, function (i, v) {
            _html += '<div class="list clearfix">\n' +
                '            <div class="a1 clearfix">\n';
            if(v.isadd == 1){
                _html += '                <p class="p1">+'+v.nums+'</p>\n';
            }else{
                _html += '                <p class="p1">-'+v.nums+'</p>\n';
            }
            _html += '                <p class="p2">'+v.ctime+'</p>\n' +
                '            </div>\n' +
                '            <div class="a2">\n' +
                '                <p class="p1">'+v.info+'</p>\n' +
                '            </div>\n' +
                '        </div>';
        })
        return _html;
    }
</script>